# -*- coding = utf-8 -*-
# @Time : 2021/7/15 8:58
# @Author : 龙王赘婿_彪少
# @File : testBs4.py
# @Software: PyCharm

from bs4 import BeautifulSoup

file = open("./baidu.html", "rb")
myhtml = file.read()

#解析器 变成树结构
bs = BeautifulSoup(myhtml, "html.parser")

# print(bs.title)
# print(bs.a)
# print(bs.head)

# print(type(bs.head))
#1.tag 标签及其内容：拿到它所找到的第一个内容

# print(bs.title.string)
# print(type(bs.title.string))
#2.NavigableString 标签里的内容

#字典提取 标签的属性，用键值对保存
# print(bs.a.attrs)

# print(type(bs))
#3. BeautifulSoup 表示整个文档

# print(bs.name)
# print(bs)

# print(bs.a.string)
# print(type(bs.a.string))
#4. Comment 注释